package com.lm.ledger.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class RoleAction extends ActionSupport{

	private HttpServletRequest request;
	private String role;
	
	public String execute(){
	//	HttpServletRequest servletRequest = ServletActionContext.getRequest();
		ActionContext  context = ActionContext.getContext();
		Map session = context.getSession();
		String userRole = getRole();
		System.out.println("role === "+userRole);
		session.put("USERROLE", userRole);
	//	System.out.println("servletRequest---- "+servletRequest);
		//HttpSession session = servletRequest.getSession();
		//session.setAttribute("USERROLE", userRole);
		//System.out.println("USERROLE from session "+session.getAttribute("USERROLE"));
		return SUCCESS;
	}
	public String getRole() {
		return role;
	}
	public void setRole(String role) {
		this.role = role;
	}
	public HttpServletRequest getRequest() {
		return request;
	}
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	
}
